package com.yy.mapper;

import com.yy.pojo.ArticleLogs;
import com.yy.pojo.vo.ArticleLogsVo;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface ArticleLogsMapper {
    /**
     * 添加文章日志
     * @param articleId
     * @param userId
     */
    @Insert("insert into article_logs(article_id,user_id,create_time) values(#{articleId},#{userId},now())")
    Integer add(Integer articleId, Integer userId);

    /**
     * 获取文章浏览记录
     * @param userId
     * @return
     */
    //根据只要前十条并根据创建时间排序
    @Select("select * from article_logs where user_id = #{userId} order by create_time desc limit 10")
    List<ArticleLogs> list(Integer userId);
}
